<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>阻止默认行为</title>
    <style>
        *{margin: 0;padding:0;box-sizing: border-box}
        html,body,#root{
            width: 100vw;
            height: 100vh;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div id="root">
        <h1>阻止默认行为</h1>
        <a href="http://www.atguigu.com">尚硅谷</a>
        <input type="text">
    </div>

    <script>
        let root = document.querySelector("#root");
        let a = document.querySelector('a');
        let input = document.querySelector('input');
        root.addEventListener('touchstart', function(e){
            e.preventDefault();
        });

        a.addEventListener('touchstart', function(e){
            e.stopPropagation();
        });
        input.addEventListener('touchstart', function(e){
            e.stopPropagation();
        });
    </script>
</body>
</html>